/* global Cesium */
const viewerInit = function() {
	const viewer = new Cesium.Viewer('cesiumContainer', {
		baseLayerPicker: false, //图层选择器
		animation: false, //左下角仪表
		fullscreenButton: false, //全屏按钮
		geocoder: false, //右上角查询搜索
		infoBox: false, //信息框
		homeButton: false, //home按钮
		sceneModePicker: false, //3d 2d选择器
		selectionIndicator: false, //
		timeline: false, //时间轴
		navigationHelpButton: false, //右上角帮助按钮
		skyBox: new Cesium.SkyBox({
			sources: {
				positiveX: require('@/assets/skyBox/tycho2t3_80_px.jpg'),
				negativeX: require('@/assets/skyBox/tycho2t3_80_mx.jpg'),
				positiveY: require('@/assets/skyBox/tycho2t3_80_py.jpg'),
				negativeY: require('@/assets/skyBox/tycho2t3_80_my.jpg'),
				positiveZ: require('@/assets/skyBox/tycho2t3_80_pz.jpg'),
				negativeZ: require('@/assets/skyBox/tycho2t3_80_mz.jpg')
			}
		}),
		imageryProvider: new Cesium.TileMapServiceImageryProvider({
			url: Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
		})
	})
	//浅拷贝
	window.viewer = viewer
	viewer.cesiumWidget.creditContainer.style.display = 'none'
	//viewer.scene.debugShowFramesPerSecond = true;
	// viewer.resolutionScale = 0.8
	if (!window.isOnline) {
		let image = new Cesium.WebMapServiceImageryProvider({
			url: 'http://36.112.11.166:8310/tilecache/service/wms',
			layers: `image_globle_base-JPEG-4326`,
			parameters: {
				service: 'WMS',
				format: 'image/png',
				style: 'default'
			}, //tileWidth:256, //tileHeight:256,
			srs: 'EPSG:4326'
		})
		let gugeLabel = new Cesium.WebMapServiceImageryProvider({
			url: 'http://36.112.11.166:8310/tilecache/service/wms',
			layers: 'Hainan_ImageLabel-PNG-4326',
			parameters: {
				service: 'WMS',
				format: 'image/png',
				style: ''
			}

			// url: 'http://221.1.66.166:8320/tilecache/service/wmts',
			// layer: 'Global_Image-JPEG-4326',
			// parameters: {
			// 	service: 'WMTS',
			// 	format: 'image/png',
			// 	style: 'default'
			// }
		})
		viewer.imageryLayers.addImageryProvider(image)
		viewer.imageryLayers.addImageryProvider(gugeLabel)
		//地形
		// window.dx = new Cesium.CesiumTerrainProvider({
		//     url:'https://www.supermapol.com/realspace/services/3D-stk_terrain/rest/realspace/datas/info/data/path',
		//     requestWaterMask:false ,
		//     requestVertexNormals: false
		// })
		// viewer.scene._terrainExaggeration = 1.5
		// viewer.terrainProvider = window.dx
	} else {
		//影像
		viewer.imageryLayers.addImageryProvider(
			new Cesium.WebMapTileServiceImageryProvider({
				url: window.baseLayer.url,
				layer: window.baseLayer.layer,
				style: window.baseLayer.style,
				format: window.baseLayer.format,
				tileMatrixSetID: window.baseLayer.tileMatrixSetID,
				tilingScheme: new Cesium.GeographicTilingScheme()
			})
		)
		//地名
		viewer.imageryLayers.addImageryProvider(
			new Cesium.WebMapTileServiceImageryProvider({
				url: window.labelLayer.url,
				layer: window.labelLayer.layer,
				style: window.labelLayer.style,
				format: window.labelLayer.format,
				tileMatrixSetID: window.labelLayer.tileMatrixSetID,
				tilingScheme: new Cesium.GeographicTilingScheme()
			})
		)
		//expo
		viewer.imageryLayers.addImageryProvider(
			new Cesium.WebMapTileServiceImageryProvider({
				url: 'http://172.25.110.35:8310/tilecache/service/wmts',
				layer: 'HNDOM_expo-PNG-4326',
				style: 'default',
				format: 'image/PNG',
				tileMatrixSetID: 'EPSG:4326',
				tilingScheme: new Cesium.GeographicTilingScheme()
			})
		)
		//地形
		// window.dx = new Cesium.CesiumTerrainProvider({
		//     url: window.terrainUrl,
		//     requestWaterMask:true,
		//     requestVertexNormals: true
		// })
		// viewer.terrainProvider = window.dx
		// viewer.scene._terrainExaggeration = 1.5
	}
}
export default viewerInit
